package com.mydistibute.distibutelearn.threadcreateway;

import java.util.concurrent.*;

/**
 * @author victorydeng
 * @Classname CreateWay3
 * @Description TODO
 * @Date 2020/5/26 11:27
 * @Created by victorydeng
 */
public class CreateWay3 implements Callable<String> {
    @Override
    public String call() throws Exception {
        System.out.println("callable");
        Thread.sleep(3000);
        return "success";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        CreateWay3 t= new CreateWay3();
        Future<String> submit = executorService.submit(t);
        //会有阻塞
        String s = submit.get();
        System.out.println(s);


    }
}
